var query = MemberTable.Where(x=>x.sex.Equals(Sex)) if (members != null) query = query.Where(x=>members.Contains(x.membercode)) //use your query query.ToList();